package com.zw.utils.encrypt;

import java.math.BigInteger;

public class DataUploadEncryptUtils {
    private RSAAlgorithm rsa;
    private PaillierAlgorithm paillier;

    public DataUploadEncryptUtils() {
        this.paillier = new PaillierAlgorithm(); // 初始化 Paillier 实例
    }

    public DataUploadEncryptUtils(RSAAlgorithm rsa, PaillierAlgorithm paillier) {
        this.rsa = rsa;
        this.paillier = paillier;
    }

    // 数据加密（根据用户选择算法）
    public BigInteger encryptData(String algorithm, BigInteger data) {
        if ("RSA".equalsIgnoreCase(algorithm)) {
            return rsa.rsaEncrypt(data);
        } else if ("Paillier".equalsIgnoreCase(algorithm)) {
            return paillier.encrypt(data);
        }
        throw new IllegalArgumentException("不支持的加密算法");
    }

    // 暴露 Paillier 实例用于解密（实际项目中可优化访问控制）
    public PaillierAlgorithm getPaillier() {
        return paillier;
    }
}
